package com.senjoeson.netlib.http;

import java.util.HashMap;
import java.util.Map;

/**
 * @author sunqiao
 * @date 2018/7/12 11:56
 */

public class HttpHelper implements IHttpProcessor {
    private static IHttpProcessor mIHttpProcessor;
    private static HttpHelper instance;
    private Map<String, Object> mParams;

    public HttpHelper() {
        mParams = new HashMap<>();
    }

    public static HttpHelper getInstance() {
        if (instance == null) {
            synchronized (HttpHelper.class) {
                if (instance == null) {
                    return instance = new HttpHelper();
                }
            }
        }
        return instance;
    }

    public static void init(IHttpProcessor iHttpProcessor) {
        mIHttpProcessor = iHttpProcessor;
    }

    @Override
    public void post(String url, Map<String, Object> params, CallBack iCallBack) {
        //事实上 这里应该去对url进行拼接
        mIHttpProcessor.post(url, params, iCallBack);
    }

    @Override
    public void get(String url, Map<String, Object> params, CallBack iCallBack) {
        mIHttpProcessor.get(url, params, iCallBack);
    }
}
